home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / pc_board / grafd211.zip / GRAF-D.PPS < prev    next >
Text File  |  1993-05-27  |  9KB  |  234 lines

  1. ;*****************************************************************************
  2. ;*                                                                           *
  3. ;*                           ANSI DETECTION V2.1                             *
  4. ;*                                                                           *
  5. ;*                        written by: Steve Catmull                          *
  6. ;*                 additional coding: David Terry                            *
  7. ;*                                                                           *
  8. ;*                            started: 04-26-93                              *
  9. ;*                                                                           *
  10. ;*****************************************************************************
  11.  
  12.  
  13. BOOLEAN hasansi     ; Result of ANSI - detection test (true or false)
  14. BOOLEAN hasrip      ; Result of ANSI - detection test (RIP & ANSI)
  15. STRING  graphdef    ; Stores response to the "ask" prompt below
  16. STRING  ask         ; Constant that contains "want graphics" minus default resp.
  17. INTEGER numticks    ; Used to store number of clock ticks that I have waited.
  18. INTEGER maxticks    ; Stores the maximum number of ticks to wait for response.
  19. STRING  temp        ; Stores the token of what user inputed.
  20. STRING  default_yes ; Used to store setting from PCBOARD.DAT for the default
  21. STRING  rest_ANSI   ; Store rest of input buffer if any after ANSI CPR.
  22. STRING  temp_dir    ; Temporary/work directory as defined in PCBSetup
  23. STRING  bkspace     ; Sequence of characters for destructive backspace  dwt
  24. STRING  esc         ; Constant used instead of chr(27)
  25. STRING  cr_lf       ; Constant used instead of chr(13)+chr(10)
  26.  
  27. BOOLEAN recorded    ; temporary.  Delete -- not needed.  SLC 04/28/93
  28. BOOLEAN compatible  ; Used to determine is sysop wants to use compatible mode.
  29. STRING  nonews      ; For parsing out what user enters
  30. STRING  nowelc      ; For parsing out what user enters
  31. STRING  ansi        ; For parsing out what user enters
  32. STRING  rip         ; For parsing out what user enters
  33. STRING  noansi      ; For parsing out what user enters
  34. STRING  autoansr    ; Used to skip graphics question if graphics detected
  35.  
  36. temp    = ""                             ; Initialized to non null for WHILE
  37. bkspace = chr(8)+chr(32)+chr(8)          ; destructive backspace  dwt
  38. maxticks = 50   ; (50/18.2 seconds)
  39. esc = chr(27)
  40. cr_lf = chr(13)+chr(10)
  41.  
  42. ; Analyze Command line passed
  43.  
  44. temp=gettoken()
  45. while (temp != "") DO
  46.    if (mid(upper(temp),2,1) = "W") then
  47.       maxticks = mid(temp,instr(temp,":")+1,2)
  48.       if (maxticks < 1 | maxticks = "")  maxticks=50
  49.    else if (mid(upper(temp),2,1) = "C") then
  50.       compatible = true
  51.    else if (mid(upper(temp),2,1) = "A") then
  52.       autoansr = true
  53.    endif
  54.    temp=gettoken()
  55. endwhile
  56. temp="" ; Return temp how we found it.
  57.  
  58.  
  59. ; /* Notifying the user that ANSI detection is being processed.  This keeps
  60. ;    them entertainment while the "ansitime" pause is being executed.  */
  61.  
  62. PRINTLN "Testing your system capability..."   ; Amusing the caller.
  63.  
  64. ; /* If you user is connected locally then default autoamtically to ANSI
  65. ;    capable.  Otherwise, send out the escape sequence to get the current
  66. ;    cursor position.  Immediately follow that with a bunch of backspace
  67. ;    space backspace sequences in case they do not have the ability to
  68. ;    interpret ANSI.  Otherwise, it may be left on the screen.  Finally,
  69. ;    wait for the and ESC followed by a left bracket to be returned.  This
  70. ;    is the only constant part of the ANSI detection that can be tested.
  71. ;    If that sequence is returned within ANSITIME seconds, then the caller
  72. ;    is considered to be ANSI capable and the HASANSI variable shows it.
  73. ;
  74. ;    NOTE:  Evidently some terminal programs are quite lazy in returning
  75. ;           the response to the ANSI detection test.  This PPE does not
  76. ;           attempt to make any accomodations for those programs.  Instead,
  77. ;           it waits "ANSITIME" seconds and then continues with the best that
  78. ;           has been determined by that time.                            */
  79.  
  80.  
  81. if (onlocal()) then
  82.    hasansi=TRUE
  83. else
  84.    print esc+"[!"
  85.    print bkspace+bkspace+bkspace
  86.    print esc+" F"
  87.    print bkspace+bkspace+bkspace
  88.    print esc+"[6n"
  89.    print bkspace+bkspace+bkspace+bkspace
  90.  
  91.    temp = chr(mgetbyte())
  92.  
  93.    while (temp = "" & numticks <= maxticks) do
  94.       temp = chr(mgetbyte())
  95.       if (temp != "") then
  96.          recorded = true
  97.       else
  98.          delay 2
  99.          numticks = numticks + 2
  100.       endif
  101.    endwhile
  102.  
  103.    if (temp = "R") then
  104.       while (temp != "" | len(rest_ansi) < 9) do
  105.          rest_ansi=rest_ansi+temp
  106.          temp=chr(mgetbyte())
  107.          if (temp = "") then
  108.            delay 2
  109.            temp = chr(mgetbyte())
  110.          endif
  111.       endwhile
  112.       if (left(rest_ansi,3)="RIP") then
  113.          hasrip=TRUE
  114.          hasansi=TRUE
  115.       endif
  116.    else if (temp = esc) then
  117.       while (temp != "") do
  118.          rest_ansi=rest_ansi+temp
  119.          temp=chr(mgetbyte())
  120.          if (temp="") then
  121.             delay 2
  122.             temp = chr(mgetbyte())
  123.          endif
  124.       endwhile
  125.       tokenize rest_ansi
  126.       temp = gettoken()
  127.       temp = mid(temp,2,len(temp-1))
  128.       if ((temp >= 0 | temp <= 80) & (right(GETTOKEN(),1)="R")) then
  129.          hasansi=TRUE
  130.       else
  131.          hasansi=FALSE
  132.       endif
  133.    endif
  134. endif
  135.  
  136.  
  137. ; /* Assign ASK variable to prompt used for ANSI.  The default if enter is
  138. ;    pressed is ommitted so that it may be built according to their ANSI
  139. ;    capabilities.                                                       */
  140.  
  141. ask = "Do you want graphics (Enter)="
  142.  
  143. ; /* Read line #257 in PCBOARD.DAT to find out what the default for the
  144. ;    "Do you want graphics" prompt is.  Store the result in DEFAULT_YES.
  145.  
  146. default_yes = READLINE(PCBDAT(),257)
  147.  
  148. ; /* If the default to the "Do you want graphics prompt is "Yes", then
  149. ;    inform the sysop via a message that the system is configured improperly. */
  150.  
  151. IF (default_yes) THEN
  152.    temp_dir = READLINE(PCBDAT(),179)
  153.    SPRINTLN
  154.    SPRINTLN "┌───────────────────────────────────────────────────────────────────┐"
  155.    SPRINTLN "│ Your system is improperly configured for use with the GRAF-D.PPE  │"
  156.    SPRINTLN "│ file.  You have configured it to default to Yes for the 'Do you   │"
  157.    SPRINTLN "│ want graphics' prompt.  You need to change that setting to 'N' in │"
  158.    SPRINTLN "│ PCBSetup | Configuration Options | Configuration Switches.        │"
  159.    SPRINTLN "└───────────────────────────────────────────────────────────────────┘"
  160.    SPRINTLN
  161.    PRINT "Do you want graphics (Enter)=no"
  162.    END
  163. ENDIF
  164.  
  165. ; /* If the user is capable of ANSI, then default for the "want graphics"
  166. ;    prompt will be Yes, otherwise, the default is set to "N".  The point
  167. ;    in asking the question is to enable the user to still choose if they
  168. ;    wish to see color or not, but if they do not know how to answer the
  169. ;    question, then the default will give them color if they are capable
  170. ;    of handling it.
  171.  
  172. IF (hasansi) THEN
  173.  
  174.    IF (hasrip) THEN
  175.       if (compatible) then
  176.          println cr_lf + esc+"[45;30m▓▒░"+esc+"[37;1m     RIPscrip detected and it will be the default    "+esc+"[0m"+esc+"[45;30m ░▒▓"+esc+"[0m"
  177.       else
  178.          ask=ask+"RIPscrip"
  179.       endif
  180.    ELSE
  181.       if (compatible) then
  182.          println cr_lf + esc+"[45;30m▓▒░"+esc+"[37;1m     ANSI detected and it will be the default    "+esc+"[0m"+esc+"[45;30m ░▒▓"+esc+"[0m"
  183.       else
  184.          ask=ask+"yes"
  185.       endif
  186.    ENDIF
  187.  
  188.    if (compatible) ask = ask + "default"
  189.  
  190. ELSE
  191.    if (compatible) then
  192.       println cr_lf + "[* No graphics capabilities detected.  This will be the default *]"
  193.       ask = ask + "default"
  194.    else
  195.       ask=ask+"no"
  196.   endif
  197. ENDIF
  198.  
  199. if ((autoansr & ! hasansi)  | !autoansr) then         ; Skip if user has ANSI and AUTO stuff is enabled
  200.  
  201.    INPUTSTR ask,graphdef,07,6,"QSR",FIELDLEN+LFBEFORE+LFAFTER+STACKED+UPCASE+YESNO
  202.    IF (graphdef="" & !hasansi) graphdef=NOCHAR()
  203.  
  204.    ; /* Now that the "want graphics" prompt has been faked so that the default
  205.    ;    value could be controlled, it is time to stuff the users response to
  206.    ;    the fake prompt to the real prompt.  This inludes the "Q and NS"
  207.    ;    parameters.                                                           */
  208.  
  209.    if (instr(graphdef,"NS")) then
  210.       nonews="NS"
  211.       graphdef=left(graphdef,instr(graphdef,"NS")-1)+right(graphdef,len(graphdef)-(instr(graphdef,"NS")+1))
  212.    endif
  213.  
  214.    if (instr(graphdef,yeschar())) ansi = yeschar()+";"
  215.    if (instr(graphdef,nochar())) noansi = nochar()+";"
  216.    if (instr(graphdef,"Q")) nowelc = "Q;"
  217.    if (instr(graphdef,"R")) rip = "R;"
  218.  
  219. endif
  220.  
  221.    if (hasrip & noansi = "" & ansi = "") then
  222.       rip = "R;"
  223.    else if (hasansi & noansi = "" & rip = "") then
  224.       ansi = yeschar()+";"
  225.    endif
  226.  
  227.    if (rip != "" & ansi != "") rip = ""
  228.    if (rip != "" & noansi != "") rip = ""
  229.    if (ansi != "" & noansi != "") ansi = ""
  230.  
  231. KBDSTUFF rip+ansi+noansi+nowelc+nonews
  232.  
  233. END                                    ; end of script
  234.